<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>

<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
        <meta name="format-detection" content="telephone=no,email=no,adress=no" />
        <META HTTP-EQUIV="luxiaoqing" CONTENT="no-cache">

        <title>69圈城-商家</title>
        
        <jsp:include page="../lbi/merCommon.jsp"></jsp:include>
        
    </head>

    <body>
        <!--头部-->
        <div class="business_top">
            <jsp:include page="../lbi/merHead.jsp"></jsp:include>

            <div class="clear"></div>
        </div>
        <!--头部end-->

        <div class="clear4"></div>

        <!--中间-->
        <div class="individual_form-center">
            <!--左边导航部分-->
            <jsp:include page="../lbi/merLeft.jsp"></jsp:include>
            <!--左边导航部分end-->

            <!--右边详情部分-->
            <div class="individual_form-center-right">
                <!--所在位置-->
                <div class="individual_form-center-right-position">
                    <span class="span01">系统设置</span>

                    <span class="span01">></span>

                    <span class="span01">修改密码</span>
                </div>
                <!--所在位置end-->

                <div class="clear"></div>

                <div class="individual_form-center-right-details">
                    <div class="individual-form-set_phone">
                        <form method='post' id="loginForm" >
                        <%-- action="<c:url value="/merchant/updatePws.do"/>" --%>
                            <input type="hidden" id="shopId" name="shopId" value="${shopId }">
                            
                            <div class="individual-form-set_phone-form">
                                <div class="clear3"></div>

                                <div class="individual-form-set_phone-form-demo">
                                    <div class="individual-form-set_phone-form-demo-span">
                                        请输入旧密码
                                    </div>

                                    <div class="individual-form-set_phone-form-demo-input">
                                        <input type="password" id="old_password" name='old_password' />
                                    </div>
                                    <div class="clear"></div>
                                </div>
                                <div class="clear3"></div>

                                <div class="individual-form-set_phone-form-demo">
                                    <div class="individual-form-set_phone-form-demo-span">
                                        请输入新密码
                                    </div>

                                    <div class="individual-form-set_phone-form-demo-input">
                                        <input type="password" id="new_password" name='new_password' />
                                    </div>

                                    <div class="clear"></div>
                                </div>

                                <div class="clear3"></div>
                                <div class="individual-form-set_phone-form-demo">
                                    <div class="individual-form-set_phone-form-demo-span">
                                        再次确认密码
                                    </div>

                                    <div class="individual-form-set_phone-form-demo-input">
                                        <input type="password" id="password1" name='password' required />
                                    </div>

                                    <div class="clear"></div>
                                </div>

                                <div class="clear3"></div>

                                <div class="individual-form-set_phone-form-sub">
                                    <input type="button" value="提&nbsp;&nbsp;&nbsp;&nbsp;交" onclick="updatePws();"/>
                                </div>

                                <div class="clear3"></div>

                               <!--  <div class="individual-form-set_phone-form-span">
                                    注：1.本公司承诺不会对外泄露您的手机号码及用于其他任何商业用途。<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2.某某某。
                                </div> -->
                            </div>
                        </form>
                    </div>

                    <div class="clear"></div>
                    
                </div>
            </div>
            <!--右边详情部分end-->

            <div class="clear2"></div>
        </div>
        <!--中间end-->

        <div class="clear2"></div>

        <!--底部-->
        <div class="business_foot">
            <jsp:include page="../lbi/merFooter.jsp"></jsp:include>
        </div>
        <!--底部end-->

        <div class="clear8"></div>
    
    <%-- <script type="text/javascript" src="<c:url value="/js/jquery.validate.min.js"/>"></script> --%>
    
<script type="text/javascript">

    $("#password").addClass("individual_form-center-left-nav-demo-02_dj");
    
    var _serviceURL = '/69mark/merchant';// 必须设置

    /* $(document).ready(function(e) {
        
        //验证表单
         $("#loginForm").validate({
        	 submitHandler : function(form) {  //验证通过后的执行方法
                 //当前的form通过ajax方式提交（用到jQuery.Form文件）
                 $(form).ajaxSubmit({
                	 
                	 type : "POST",
                     url : _serviceURL+"/updatePws.do",
                     cache : false,
                     data : $("#loginForm").serialize(),
                     dataType : 'json',
                     success:function( data ){
                    	 if (data == 1) {
                             alert("修改成功");
                             
                             $("#old_password").val("");
                             $("#new_password").val("");
                             $("#password1").val("");
                             
                         }else if (data == 2) {
                             alert("旧密码输入错误");
                         }else {
                             alert("两次密码不一致");
                         }
                       }
                     });

             },
             focusInvalid : true,
        	 rules: {
                old_password: {
                    required: true,
                    minlength: 6,
                },
                new_password: {
                    required: true,
                    minlength: 6,
                },
                password: {
                    required: true,
                    minlength: 6,
                    equalTo: "#new_password",
                },
            },
            messages: {
                old_password: {
                    minlength: "密码不正确",
                    required: "请输入旧密码",
                },
                new_password: {
                	 required: "请重置新密码",
                	 minlength: "密码不正确",
                   
                },
                password: {
                    minlength: "密码不正确",
                    required:"请确认新密码",
                    equalTo:"密码不一致",
                }
            }
        });
    });  */
    
   
    
    function updatePws(){
    	var old_password = $("#old_password").val();
    	var new_password = $("#new_password").val();
    	var password = $("#password1").val();
    	var shopId = $("#shopId").val();
    	
    	if (old_password == "") {
    		alert("旧密码不能为空");
            return false;
    	}else if (new_password == ""){
    		alert("新密码不能为空");
            return false;
    	}else if (password == ""){
    		alert("二级密码不能为空");
            return false;
        }else if (new_password != password) {
            alert("两次密码不一致");
            return false;
        }
    	
    	$.ajax({
            type : "POST",
            url : _serviceURL+"/updatePws.do",
            cache : false,
            //data : "shopId="+shopId+"&old_password="+old_password+"&new_password="+new_password+"&password="+password,
            data : $("#loginForm").serialize(),
            dataType : 'json',
            success : function(data) {
            	if (data == 1) {
            		alert("修改成功");
            		
            		$("#old_password").val("");
            		$("#new_password").val("");
            		$("#password1").val("");
            		
            	}else if (data == 2) {
            		alert("旧密码输入错误");
            	}else {
            		alert("两次密码不一致");
            	}
            }
    	})
    }
    

    
</script>

    </body>

</html>